package com.icas.util.md5;

import java.util.Random;

/**
 * @Author: tocchen
 * @Date: 2022/4/3 15:14
 * @Description:
 **/
public class SaltUtils {
    /**
     * 获取加密盐
     * @param n 设置加密盐个数
     * @return 返回盐
     */
    public static String getSalt(Integer n){
        StringBuilder salt = new StringBuilder();
        char[] chars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz1234567890<>,.?/}{!@#$%^&*()".toCharArray();
        for (int i=0;i<n;i++){
            salt.append(chars[new Random().nextInt(chars.length)]);
        }
        return salt.toString();
    }
}
